import http from "@/utils/request";

export const getOrder = (params) => {
  //返回订单列表
  return http.get("/order/page", {
    params: {
      type: params.type,
      curPage: params.curPage,
      limit: params.limit,
      name: params.sname,
    },
  });
};

export const getSupplier = (params) => {
  //返回供应商列表
  return http.get("/supplier/list");
};

export const editOrder = (data) => {
  //更新订单信息
  return http.post("/order/editOrder", {
    oid: data.oid,
    wid: data.wid,
    did: data.did,
    prchsNum: data.prchsNum,
    address: data.address,
    prchsUser: data.prchsUser,
    updWarehouse: data.updWarehouse,
    state: data.state,
  });
};
export const delOrder = (param) => {
  //删除订单信息
  const myparams = new URLSearchParams();
  myparams.append("oid", param);
  return http.post("/order/delOrder", myparams);
};

export const addOrder = (data) => {
  //更新订单信息
  const myparams = new URLSearchParams();
  return http.post("/order/addDrugThroughAdmin", {
    did: data.did,
    prchsNum: data.prchsNum,
    address: data.address,
    prchsUser: data.prchsUser,
    updWarehouse: data.updWarehouse,
  });
};

export const retOrder = (data) => {
  //提交退货信息
  const myparams = new URLSearchParams();
  return http.post("/userRetInfo/submitProblemOrder", {
    oid: data.oid,
    problemType: data.problemTypeId,
    reason: data.retReason,
  });
};
